import tabBar from "@/utils/tabBar.js"
const state = {
	list: [],
	current: 0,
	index: '',
}
const mutations = {
	SET_LIST: (state, data) => {
		state.list = data;
	},
	SET_CURRENT: (state, data) => {
		state.current = data;
	},
	SET_INDEX: (state, index) => {
		state.index = index;
	},
}
const actions = {
	//根据角色加载菜单
	changeRole({
		state,
		commit
	}, data) {
		return new Promise((resolve) => {
			commit('SET_LIST', tabBar[data.key](data.value));
			commit('SET_INDEX', state.list[0].pagePath);
			commit('SET_CURRENT', 0);
			resolve();
		})
	},
}
export default {
	state,
	mutations,
	actions
}